#ifndef _ICE_QUEUE_H_
#define _ICE_QUEUE_H_
#include <list>
#include "iceutil/monitor.h"

template<typename T> class Queue 
{
public:
	void put(const T& item)
	{
		IceUtil::Monitor<IceUtil::Mutex>::Lock lock(&m_mutex);
		m_queue.push_back(item);
		if(m_queue.size() == 1)
		{
			m_mutex.notify();
		}
	}
	void get()
	{
		IceUtil::Monitor<IceUtil::Mutex>::Lock lock(&m_mutex);
		while(m_queue.size() == 0)
		{
			m_mutex.wait();
		}
		T item = m_queue.front();
		m_queue.pop_front();
		return item;
	}

private:
	IceUtil::Monitor<IceUtil::Mutex> m_mutex;
	std::list<T> m_queue;
};


#endif